Store function signatures instead of FuncOp handles in functionMap (§2)#214
Merged
Conversation
…eview doc 2) NamespaceInfo::functionMap cached raw mlir_ts::FuncOp handles; since the discovery pass emits into a throwaway module (#213), any handle registered during discovery is guaranteed to dangle once the module is erased - consumers survived only because they read the (context-owned) type early. The map now stores FunctionEntry { symbol name, function type }, which is all any consumer used; the one site that needs a live op (generic-instantiation short-circuit) resolves it through theModule.lookupSymbol with a short/full-name fallback. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements §2 from
docs/MLIRGen-refactoring-review.mdforNamespaceInfo::functionMap.The map cached raw
mlir_ts::FuncOphandles. Since #213 routed the discovery pass into a throwaway module, any handle registered during discovery is guaranteed to dangle once that module is erased — consumers survived only because they read the (MLIRContext-owned, always-safe) function type early. Now:functionMapstores aFunctionEntry{ symbol name (std::string— aStringRefwould dangle with the op's attribute storage),mlir_ts::FunctionType}, which is everything any consumer actually used.mlirGenFunctionLikeDeclaration— resolves it throughtheModule.lookupSymbol<mlir_ts::FuncOp>with a short-name → full-name fallback, so it returns an op from the current module rather than a possibly-stale cached handle.Test plan
The full suite earned its keep here: the first full run caught a real regression — my initial short-circuit rewrite resolved by short name only, returning null where the original returned the cached (full-symbol) op, failing
funcs-nesting-captureandany-generic-equalsin both compile and JIT modes. The fallback fixed it.-j8) — full AOT + JIT + unittests🤖 Generated with Claude Code